<!DOCTYPE html>
<style>
  body {
    margin: 0;
  }
  iframe {
    height: 900px;
    width: 900px;
    margin-left: 51px;
    margin-top: 52px;
    border: none;
  }
</style>

<script>
  // Prefer non-composited scrolling because this is a test of non-composited
  // scrollers.
  if (window.internals)
    internals.runtimeFlags.preferNonCompositedScrollingEnabled = true;
</script>

<iframe id='iframe' src='resources/iframe-containing-non-fast-scrollables.html'></iframe>

<script src="resources/non-fast-scrollable-region-testing.js"></script>
<script src="../resources/run-after-layout-and-paint.js"></script>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
  async_test((t) => {
    var iframeWindow = document.querySelector("iframe").contentWindow;
    iframeWindow.addEventListener("load", () => {
      t.step(function() {
        nonFastScrollableRects = internals.nonFastScrollableRects(document);
        assert_equals(nonFastScrollableRects.length, 2);
        var rectStrings = [];
        for (var rect of nonFastScrollableRects)
          rectStrings.push(rectToString(rect));
        rectStrings.sort();
        assert_equals(rectStrings[0], '[51, 102, 200, 200]');
        assert_equals(rectStrings[1], '[51, 402, 211, 211]');
        var iframeElement = document.querySelector("iframe");
        iframeElement.style.visibility = 'hidden';
      });

      runAfterLayoutAndPaint(() => {
        t.step(function() {
          nonFastScrollableRects = internals.nonFastScrollableRects(document);
          assert_equals(nonFastScrollableRects.length, 0);
        });
        t.done();
      });
    });
  }, "This test ensures that non-fast scrollable area is re-computed on FrameView visibility changes.");
</script>
